The present invention relates generally to computer processing systems, and more particularly to a perceptron branch predictor with virtualized weights in a processing system.
An instruction pipeline in a computer processor improves instruction execution throughput by processing instructions using a number of pipeline stages, where multiple stages can act on different instructions of an instruction stream in parallel. A conditional branch instruction in an instruction stream may result in a pipeline stall if the processor waits until the conditional branch instruction is resolved in an execution stage in the pipeline before fetching a next instruction in an instruction fetching stage for the pipeline. A branch predictor may attempt to guess whether a conditional branch will be taken or not. A branch predictor may also include branch target prediction, which attempts to guess a target of a taken conditional or unconditional branch before it is computed by decoding and executing the instruction itself. A branch target may be a computed address based on an offset and/or an indirect reference through a register. A throughput penalty is incurred if a branch is mispredicted.
A branch target buffer (BTB) can be used to predict the target of a predicted taken branch instruction based on the address of the branch instruction. Predicting the target of the branch instruction can prevent pipeline stalls by not waiting for the branch instruction to reach the execution stage of the pipeline to compute the branch target address. By performing branch target prediction, the branch's target instruction decode may be performed in the same cycle or the cycle after the branch instruction instead of having multiple bubble/empty cycles between the branch instruction and the target of the predicted taken branch instruction. Other branch prediction components that may be included in the BTB or implemented separately include a branch history table and a pattern history table. A branch history table can predict the direction of a branch (taken vs. not taken) as a function of the branch address. A pattern history table can assist with direction prediction of a branch as a function of the pattern of branches encountered leading up to the given branch which is to be predicted.
Perceptron branch predictors are simple artificial neural networks that predict a branch's direction by learning correlations between bits in a history vector and the branch outcome using a plurality of weights. This typically requires storing signed integer weights for each bit in the history vector. Perceptron branch predictors provide highly accurate predictions but are expensive in terms of silicon area required to store the weights and expensive in terms of area and cycle time to compute the prediction.